import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
    {
      path:'/index',
      component:()=>import('../pages/index'),
      children:[
        {
          path:'/home',
          component:()=>import('../views/home'),
          name:'首页'
        },
        {
          path:'/cate',
          component:()=>import('../views/cate'),
          name:'分类'
        },
        {
          path:'/cart',
          component:()=>import('../views/cart'),
          name:'购物车'
        },
        {
          path:'/mine',
          component:()=>import('../views/mine'),
          name:'个人中心'
        },
        {
          path:'',
          redirect:'/home'
        },
      ],
    },
    {
      path:'/detail',
      component:()=>import('../pages/detail'),
      name:"商品详情"
    },
    {
      path:'/register',
      component:()=>import('../pages/register'),
      name:"注册"
    },
    {
      path:'/list',
      component:()=>import('../pages/list'),
      name:"列表"
    },
    {
      path:'/login',
      component:()=>import('../pages/login'),
      name:"登录"
    },
    {
      path:'/order',
      component:()=>import('../pages/order'),
      name:"订单页"
    },
    {
      path:'*',
      redirect:'/index'
    }
]

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes
})

export default router
